define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'service/service/index' + location.search,
                    add_url: 'service/service/add',
                    edit_url: 'service/service/edit',
                    del_url: 'service/service/del',
                    multi_url: 'service/service/multi',
                    import_url: 'service/service/import',
                    table: 'service',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                showExport:false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'info', title: __('Info'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // 1定金保障 2会员权益 3入会须知 4视频教程 5功能介绍
                        {field: 'type', title: __('type'), searchList: {1:"定金保障",2:"会员权益",3:"入会须知",4:"视频教程",5:"功能介绍",6:"隐私协议",7:"用户协议",8:"定金保障协议"},defaultValue:4, formatter: Table.api.formatter.label},
                        {field: 'status', title: __('Status'), searchList: {"0":"隐藏","1":"显示"}, formatter: Table.api.formatter.status},

                        {field: 'file', title: __('File'), operate: false, formatter: Table.api.formatter.file},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});

$(function (){
    isHide()
})

$("#c-type").change(function (obj) {


    isHide()
    //obj为SelectPage对象
    // let val = $("#c-car_brand_name").val()
    // console.log(val)
    // return {custom: {queryarr: val}};
});

function isHide(){
    let val = $("#c-type").val()
    if (val == 7 || val == 6 || val == 3 || val == 5 || val == 8) {
        $("#file").hide()
        $("#info").show()
    } else {
        $("#info").hide()
        $("#file").show()
    }
}